
package uk.org.cardboardbox.nfcpointstracker.dialog;

import uk.org.cardboardbox.nfcpointstracker.R;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

public class LoginDialog extends AlertDialog {

    private final Listener listener;

    public interface Listener {
        public boolean onLogin(String username, String password);
    }

    public LoginDialog(Context context, Listener listener) {
        super(context);
        init(context);
        this.listener = listener;
    }

    private final void init(Context context) {
        setTitle("Login");
        LinearLayout content = (LinearLayout)((LayoutInflater)context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                .inflate(R.layout.loginbox, null);
        setView(content);
        setButton(BUTTON_POSITIVE, context.getString(android.R.string.ok),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        listener.onLogin("xx", "xxx");
                    }
                });
        setButton(BUTTON_NEGATIVE, context.getString(android.R.string.cancel),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                });
    }
}
